test: add retry logic for eventloopdelay histogram sampling#61796
test: add retry logic for eventloopdelay histogram sampling#61796mcollina wants to merge 2 commits into
Conversation
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61796 +/- ##
==========================================
- Coverage 89.76% 89.71% -0.05%
==========================================
Files 675 675
Lines 204674 204797 +123
Branches 39330 39348 +18
==========================================
+ Hits 183716 183734 +18
- Misses 13235 13336 +101
- Partials 7723 7727 +4 π New features to boost your workflow:
|
On some build configurations (e.g., sharedlibs), the histogram may not record valid samples (min > 0) after the initial spinning period. This adds a retry mechanism that will spin the event loop additional times if valid samples haven't been recorded yet. This helps ensure the test passes on slower or differently-configured systems where event loop delay sampling may take longer to produce measurable results. Refs: nodejs/reliability#1461
a0b9aa0 to
ad1c0a7
Compare
Extract assertions into separate function and simplify control flow. Use setImmediate for final assertions to ensure histogram has recorded all samples.
ad1c0a7 to
64c291a
Compare
Commit Queue failed- Loading data for nodejs/node/pull/61796 β Done loading data for nodejs/node/pull/61796 ----------------------------------- PR info ------------------------------------ Title test: add retry logic for eventloopdelay histogram sampling (#61796) Author Matteo Collina <matteo.collina@gmail.com> (@mcollina) Branch mcollina:fix-flaky-test-performance-eventloopdelay-v2 -> nodejs:main Labels test Commits 2 - test: add retry logic for eventloopdelay histogram sampling - test: refactor eventloopdelay test for clarity Committers 1 - Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/61796 Refs: https://github.com/nodejs/reliability/issues/1461 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Richard Lau <richard.lau@ibm.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/61796 Refs: https://github.com/nodejs/reliability/issues/1461 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Richard Lau <richard.lau@ibm.com> -------------------------------------------------------------------------------- βΉ This PR was created on Thu, 12 Feb 2026 22:07:51 GMT β Approvals: 4 β - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/61796#pullrequestreview-3797902216 β - Colin Ihrig (@cjihrig): https://github.com/nodejs/node/pull/61796#pullrequestreview-3797906488 β - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/61796#pullrequestreview-4261607012 β - Richard Lau (@richardlau) (TSC): https://github.com/nodejs/node/pull/61796#pullrequestreview-4263460373 β Last GitHub CI successful βΉ Last Full PR CI on 2026-05-11T12:08:59Z: https://ci.nodejs.org/job/node-test-pull-request/73370/ - Querying data for job/node-test-pull-request/73370/ β Build data downloaded β Last Jenkins CI successful -------------------------------------------------------------------------------- β No git cherry-pick in progress β No git am in progress β No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD β origin/main is now up-to-date - Downloading patch for 61796 From https://github.com/nodejs/node * branch refs/pull/61796/merge -> FETCH_HEAD β Fetched commits as 0a60e9013bb9..64c291afb908 -------------------------------------------------------------------------------- [main 9caf8f098e] test: add retry logic for eventloopdelay histogram sampling Author: Matteo Collina <hello@matteocollina.com> Date: Thu Feb 12 23:07:10 2026 +0100 1 file changed, 62 insertions(+), 45 deletions(-) [main 5d9d4fb500] test: refactor eventloopdelay test for clarity Author: Matteo Collina <hello@matteocollina.com> Date: Sat Feb 14 17:47:16 2026 +0100 1 file changed, 48 insertions(+), 45 deletions(-) β Patches applied There are 2 commits in the PR. Attempting autorebase. (node:396) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated. (Use `node --trace-deprecation ...` to show where the warning was created) Rebasing (2/4)https://github.com/nodejs/node/actions/runs/25685898940 |
Commit Queue failed- Loading data for nodejs/node/pull/61796 β Done loading data for nodejs/node/pull/61796 ----------------------------------- PR info ------------------------------------ Title test: add retry logic for eventloopdelay histogram sampling (#61796) Author Matteo Collina <matteo.collina@gmail.com> (@mcollina) Branch mcollina:fix-flaky-test-performance-eventloopdelay-v2 -> nodejs:main Labels test, commit-queue-squash Commits 2 - test: add retry logic for eventloopdelay histogram sampling - test: refactor eventloopdelay test for clarity Committers 1 - Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/61796 Refs: https://github.com/nodejs/reliability/issues/1461 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Richard Lau <richard.lau@ibm.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/61796 Refs: https://github.com/nodejs/reliability/issues/1461 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Richard Lau <richard.lau@ibm.com> -------------------------------------------------------------------------------- βΉ This PR was created on Thu, 12 Feb 2026 22:07:51 GMT β Approvals: 4 β - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/61796#pullrequestreview-3797902216 β - Colin Ihrig (@cjihrig): https://github.com/nodejs/node/pull/61796#pullrequestreview-3797906488 β - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/61796#pullrequestreview-4261607012 β - Richard Lau (@richardlau) (TSC): https://github.com/nodejs/node/pull/61796#pullrequestreview-4263460373 β Last GitHub CI successful βΉ Last Full PR CI on 2026-05-11T17:29:59Z: https://ci.nodejs.org/job/node-test-pull-request/73370/ - Querying data for job/node-test-pull-request/73370/ β Build data downloaded β Last Jenkins CI successful -------------------------------------------------------------------------------- β No git cherry-pick in progress β No git am in progress β No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD β origin/main is now up-to-date - Downloading patch for 61796 From https://github.com/nodejs/node * branch refs/pull/61796/merge -> FETCH_HEAD β Fetched commits as 0a60e9013bb9..64c291afb908 -------------------------------------------------------------------------------- [main 36fc919cb8] test: add retry logic for eventloopdelay histogram sampling Author: Matteo Collina <hello@matteocollina.com> Date: Thu Feb 12 23:07:10 2026 +0100 1 file changed, 62 insertions(+), 45 deletions(-) [main cca689e6e5] test: refactor eventloopdelay test for clarity Author: Matteo Collina <hello@matteocollina.com> Date: Sat Feb 14 17:47:16 2026 +0100 1 file changed, 48 insertions(+), 45 deletions(-) β Patches applied There are 2 commits in the PR. Attempting to fixup everything into first commit. [main fb48362ff4] test: add retry logic for eventloopdelay histogram sampling Author: Matteo Collina <hello@matteocollina.com> Date: Thu Feb 12 23:07:10 2026 +0100 1 file changed, 66 insertions(+), 46 deletions(-) β Found Refs: https://github.com/nodejs/reliability/issues/1461, skipping.. --------------------------------- New Message ---------------------------------- test: add retry logic for eventloopdelay histogram samplinghttps://github.com/nodejs/node/actions/runs/25688115197 |
Summary
Fixes flaky
test-performance-eventloopdelaytest on sharedlibs builds.Problem
On some build configurations (e.g., Ubuntu 24.04 sharedlibs), the histogram may not record valid samples (
min > 0) after the initial spinning period. The test fails with:The previous fix (PR #61629) added
setImmediateto allow samples to be recorded, but this wasn't sufficient for all configurations.Solution
Add a retry mechanism that checks if valid samples have been recorded (
count > 0 && min > 0 && max > 0). If not, the test will spin the event loop additional times (up to 3 retries) before asserting.This ensures the test passes on slower or differently-configured systems where event loop delay sampling may take longer to produce measurable results.
Verification
Tested locally with
python3 tools/test.py --repeat 30- all passed.Refs: nodejs/reliability#1461